import org.rapla.plugin.freiraum.common.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



public class RaplaService  implements RaplaJsonService{

	List<ResourceDescriptor> resultsRooms;
	List<ResourceDescriptor> resultsPersons;
	List<ResourceDescriptor> resultsCourses;
		
	
	@Override
	public void getResources(String type, String categoryId,
			@SuppressWarnings("restriction") com.google.gwtjsonrpc.common.AsyncCallback<List<ResourceDescriptor>> callback) {
		
	}
		
	public void getResources(String type, String categoryId,
			 AsyncCallback<List<ResourceDescriptor>> callback) {
		
		
		if(type == "rooms"){
			
		List<ResourceDescriptor> resultsRooms = new ArrayList<ResourceDescriptor>();
		
		
		List<String> searchTermsRooms = new ArrayList<String>();
		searchTermsRooms.add("Raum");
		searchTermsRooms.add("RaumTest");
		searchTermsRooms.add("Wirtschaftsinformatik");
		
			
		ResourceDescriptor r1 = new ResourceDescriptor("01", "Testraum1", "test1.de", searchTermsRooms);
		ResourceDescriptor r2 = new ResourceDescriptor("02", "Testraum2", "test2.de", searchTermsRooms);
		ResourceDescriptor r3 = new ResourceDescriptor("03", "Testraum3", "test3.de", searchTermsRooms);
		ResourceDescriptor r4 = new ResourceDescriptor("04", "Testraum4", "test4.de", searchTermsRooms);
		ResourceDescriptor r5 = new ResourceDescriptor("05", "Testraum5", "test5.de", searchTermsRooms);
			
		resultsRooms.add(r1);
		resultsRooms.add(r2);
		resultsRooms.add(r3);
		resultsRooms.add(r4);
		resultsRooms.add(r5);
		
		callback.onSuccess(resultsRooms);	

		}
		else if(type == "persons")
		{
			
			List<ResourceDescriptor> resultsPersons = new ArrayList<ResourceDescriptor>();

						
			List<String> searchTermsPersons = new ArrayList<String>();
			searchTermsPersons.add("Person");
			searchTermsPersons.add("PersonTest");
			searchTermsPersons.add("Wirtschaftsinformatik");
			
			ResourceDescriptor p1 = new ResourceDescriptor("06", "Testperson1", "test1.de", searchTermsPersons);
			ResourceDescriptor p2 = new ResourceDescriptor("07", "Testperson2", "test2.de", searchTermsPersons);
			ResourceDescriptor p3 = new ResourceDescriptor("08", "Testperson3", "test3.de", searchTermsPersons);
			ResourceDescriptor p4 = new ResourceDescriptor("09", "Testperson4", "test4.de", searchTermsPersons);
			ResourceDescriptor p5 = new ResourceDescriptor("10", "Testperson5", "test5.de", searchTermsPersons);
					
			resultsPersons.add(p1);
			resultsPersons.add(p2);
			resultsPersons.add(p3);
			resultsPersons.add(p4);
			resultsPersons.add(p5);
							
			callback.onSuccess(resultsPersons);
		}
		
		else if(type == "courses")
		{
			
			
			List<ResourceDescriptor> resultsCourses = new ArrayList<ResourceDescriptor>();
			
			
			
			
			List<String> searchTermsCourses = new ArrayList<String>();
			searchTermsCourses.add("Kurs");
			searchTermsCourses.add("KursTest");
			searchTermsCourses.add("Wirtschaftsinformatik");
				
			ResourceDescriptor c1 = new ResourceDescriptor("11", "Testkurs1", "test1.de", searchTermsCourses);
			ResourceDescriptor c2 = new ResourceDescriptor("12", "Testkurs1", "test2.de", searchTermsCourses);
			ResourceDescriptor c3 = new ResourceDescriptor("13", "Testkurs1", "test3.de", searchTermsCourses);
			ResourceDescriptor c4 = new ResourceDescriptor("14", "Testkurs1", "test4.de", searchTermsCourses);
			ResourceDescriptor c5 = new ResourceDescriptor("15", "Testkurs1", "test5.de", searchTermsCourses);
					
			resultsCourses.add(c1);
			resultsCourses.add(c2);
			resultsCourses.add(c3);
			resultsCourses.add(c4);
			resultsCourses.add(c5);			
				
			callback.onSuccess(resultsCourses);
		}
		
	}

@Override
public void getResource(String id, @SuppressWarnings("restriction") com.google.gwtjsonrpc.common.AsyncCallback<ResourceDetail> callback) {

}

	public void getResource(String id, AsyncCallback<ResourceDetail> callback) {
		
		Map<String, ResourceDetailRow> map = new HashMap<String, ResourceDetailRow>();
		
		
		ResourceDetailRow rdr1 = new ResourceDetailRow("Raum", "A01");
		ResourceDetailRow rdr2 = new ResourceDetailRow("Raumart", "Testsaal");
		ResourceDetailRow rdr3 = new ResourceDetailRow("Name", "A01");
		ResourceDetailRow rdr4 = new ResourceDetailRow("Studiengang", "Wirtschaftsinformatik");
		ResourceDetailRow rdr5 = new ResourceDetailRow("Studiengang", "Wirtschaftsinformatik");
		id = "r01";
		
		map.put("raumnr", rdr1);
		map.put("raumart", rdr2);
		map.put("name", rdr3);
		map.put("studiengang", rdr4);
		map.put("abteilung", rdr5);
		Event e = new Event();
		List<Event> el = new ArrayList<Event>();
		
		ResourceDetail result = new ResourceDetail(map,el );
		
		callback.onSuccess(result );
	}

	@Override
	public void getOrganigram(String categoryId,
			@SuppressWarnings("restriction") com.google.gwtjsonrpc.common.AsyncCallback<List<CategoryDescription>> callback) {
		// TODO Auto-generated method stub
		
	}
	
	public void getOrganigram(String categoryId,
			AsyncCallback<List<CategoryDescription>> callback) {
		
		CategoryDescription cd1 = new CategoryDescription("cat1", "Allgemein");
		CategoryDescription cd2 = new CategoryDescription("cat2", "Gesundheitswesen");
		CategoryDescription cd3 = new CategoryDescription("cat3", "Technik");
		CategoryDescription cd4 = new CategoryDescription("cat4", "Wirtschaft");
		
		List<CategoryDescription> cds = new ArrayList<CategoryDescription>();
		cds.add(cd1);
		cds.add(cd2);
		cds.add(cd3);
		cds.add(cd4);
		callback.onSuccess(cds);
		
	}


}
